using System;
using System.Collections.Generic;
using System.Linq;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Audio;
using Microsoft.Xna.Framework.Content;
using Microsoft.Xna.Framework.GamerServices;
using Microsoft.Xna.Framework.Graphics;
using Microsoft.Xna.Framework.Input;
using Microsoft.Xna.Framework.Media;
using TiledLib;

namespace DarwinIsDead
{
    /// <summary>
    /// This is a game component.
    /// </summary>
    public class Background
    {
        private Map map;
        private SpriteBatch spriteBatch;


        public Map MAP
        {
            get { return map; }
            set { map = value; }
        }

        /// <summary>
        /// Returns a List of MapObjects with the player spawn points
        /// </summary>
        /// <returns></returns>
        public List<MapObject> getPlayerSpawn ( )
        {
			MapObjectLayer objects = map.GetLayer("Objects") as MapObjectLayer;
            List<MapObject> mapObjectList = new List<MapObject>(); 


            //TODO: Need to find a way to iterate through objects 
            mapObjectList.Add( objects.GetObject("pspwan") );
            mapObjectList.Add( objects.GetObject("pspwan1") );
            mapObjectList.Add( objects.GetObject("pspwan2") );
            mapObjectList.Add( objects.GetObject("pspwan3") );
            mapObjectList.Add( objects.GetObject("pspwan4") );
            
            return mapObjectList;
        }

        /// <summary>
        /// Returns a List of MapObjects with the Zombie spawn points
        /// </summary>
        /// <returns></returns>
        public List<MapObject> getZombieSpawn ( )
        {
			MapObjectLayer objects = map.GetLayer("Objects") as MapObjectLayer;
            List<MapObject> mapObjectList = new List<MapObject>();


            //TODO: Need to find a way to iterate through objects 
            mapObjectList.Add( objects.GetObject("spwan") );
            mapObjectList.Add( objects.GetObject("spwan1") );
            mapObjectList.Add( objects.GetObject("spwan2") );
            mapObjectList.Add( objects.GetObject("spwan3") );
            mapObjectList.Add( objects.GetObject("spwan4") );
            mapObjectList.Add( objects.GetObject("spwan5") );

            return mapObjectList;
        }
        
        public Background(World world, SpriteBatch spriteBatch) 
        {
            this.spriteBatch = spriteBatch; 
            this.map = world.Game.Content.Load<Map>("map");    
        }

        public void Draw(SpriteBatch spriteBatch) {
            
            map.Draw(spriteBatch);
        }
    }
}
